package com.IC.base.controller;

import IC.common.core.domain.R;
import com.IC.base.service.SysRoleService;
import com.IC.domain.SysRole;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：xiawenze
 * @Package：com.IC.base.controller
 * @Project：smart2
 * @name：SysRoleController
 * @Date：2024/7/29 11:30
 */
@RestController
@Log4j2
@RequestMapping("/sysrole")
public class SysRoleController {
    @Autowired
    private SysRoleService sysRoleService;


    @GetMapping("findSysRole")
    public R findSysRole(@RequestParam(name = "name") String name){
        List<SysRole> sysRoleList = sysRoleService.findSysRole(name);
        return R.ok(sysRoleList);
    }

    @PostMapping("addSysRole")
    public R addSysRole(@RequestBody SysRole sysRole){
        sysRoleService.addSysRole(sysRole);
        return R.ok();
    }

    @PostMapping("updateSysRole")
    public R updateSysRole(@RequestBody SysRole sysRole){
        sysRoleService.updateSysRole(sysRole);
        return R.ok();
    }
    @GetMapping("deleteSysRole/{id}")
    public R deleteSysRole(@PathVariable Integer id){
        sysRoleService.deleteSysRole(id);
        return R.ok();
    }
}
